package t20220204;

/**
 * @Author: DengJia
 * @Date: 2022/1/25 21:51
 * @Description:
 */

public class UseFinally {
    public static void main(String[] args) {
        for (int i = 1; i <= 4; i++) {
            useFinally(i);
        }
    }

    private static void useFinally(int i) {
        System.out.println("需要清理的初始化~");
        try {
            System.out.println("1");
            if (i == 1) {
                return;
            }
            System.out.println("2");
            if (i == 2) {
                return;
            }
            System.out.println("3");
            if (i == 3) {
                return;
            }
            System.out.println("end");
        } finally {
            System.out.println("清理工作~");
        }
    }
}
